import request from '@/common/request/request.js'
import {
	stringFormat,
	toQueryString
} from '../utils/util.js' //组件用正则 过滤传递的参数


const GET = 'GET'
const POST = 'POST'
const PUT = 'PUT'
const DELETE = 'DELETE'

/**
 * @Description:
 * 根据手机号创建用户
 * @gavin
 * 
 * @param 
 * @return 
 * 
 * @createTime: 2023-08-31 13:16:46
 */
export function getUserInfoByCode(data) {
	return request(data, "/getUserInfoByCode", GET).then(res => res)
}


/**
 * @Description:
 * 根据手机号创建用户
 * @gavin
 * 
 * @param 
 * @return 
 * 
 * @createTime: 2023-08-31 13:16:46
 */
export function verifyMobileNumber(data) {
	return request(data, "/open/auth/verifyMobileNumber"+toQueryString(data), POST).then(res => res)
}
/**
 * @Description:
 * 获取手机验证码
 * @gavin
 * 
 * @param 
 * @return 
 * @createTime: 2023-08-31 13:16:46
 */
export function sendVerificationCode(data) {
	return request(data, "/open/auth/sendVerificationCode"+toQueryString(data), POST).then(res => res)
}


// 修改用户信息
export function updateUserInfo(data) {
	return request(data, "/usermini/user/updateUserInfo", POST).then(res => res)
}




export function logout(data) {
	return request(data, "/usermini/user/logout", GET).then(res => res)
}

// 添加咨客信息
export function addGuest(data) {
	return request(data, "/storeUser/customer/add", POST).then(res => res)
}


// 编辑咨客信息
export function editGuest(data) {
	return request(data, "/storeUser/customer/edit", POST).then(res => res)
}


// 获取配置字典
export function getAllOptions(data) {
	return request(data, "/usermini/options/getAll", GET).then(res => res)
}

export function getToken(data) {
	return request(data, "/getToken", GET).then(res => res)
}

// 获取用户全部咨客
export function getGuestList(data) {
	// return request({}, "/usermini/stores/customers/guest/list", GET).then(res => res)
	return request({}, "/storeUser/getAllGuest", GET).then(res => res)
}

export function getGuestByUid(data){
  return request(data, "/customer/detail", GET).then(res => res)
}

// 获取用户全部权益
export function getUserEquity(data) {
	// return request(data, "/usermini/talktimeUserRights/getUserEquity", GET).then(res => res)
	// return request(data, "/storeUser/getUserEquityList", GET).then(res => res)
	return request(data, "/userRights/get_user_rights_list", GET).then(res => res)
}

export function getUserEquityOpts(data){
  return request(data,"/storeUser/getUserEquity",GET).then(res=>res)
}

// 获取用户鉴权token
export function getTokenOld(data) {
	return request(data, "/auth/getToken", GET).then(res => res)
}


//获取门店选项
export function getStoreOpts(data){
  return request(data,"/offline/getStore",GET).then(res=>res)
}


//获取优惠券领取情况
export function getUserDiscountInfo(data){
  return request(data,"/discount/getUserDiscountInfo",GET).then(res=>res)
}


/**
  * @Description:
  * 返回指定优惠券信息
  * @gavin
  * 
  * @param 
  * @return 
  * 
  * @createTime: 2024-08-22 16:11:39
  */
export function getAssignDiscount(data) {
	return request(data, "/discount/getAssignDiscount", GET).then(res => res)
}
/**
  * @Description:
  * 返回指定优惠券用户是否领取。 true为没有领取过
  * @gavin
  * 
  * @param 
  * @return 
  * 
  * @createTime: 2024-08-22 16:11:39
  */

export function getExtAssignDiscount(data) {
	return request(data, "/discount/getExtAssignDiscount", GET).then(res => res)
}


//领取优惠券
export function getUserDiscount(data){
  return request(data,"/discount/getUserDiscount",GET).then(res=>res)
}

//领取老用户优惠券
export function getOldUserDiscount(data){
  return request(data,"/discount/getOldUserDiscount",GET).then(res=>res)
}



//获取用户当前生效的优惠券
export function getUserDiscountTakeEffect(data){
  return request(data,"/discount/getUserDiscountTakeEffect",GET).then(res=>res)
}

//判断用户是否可0元购买测评
export function getDisCountZeroScl(data){
  return request(data,"/scl/getDisCountZeroScl",GET).then(res=>res)
}


export function getUserDiscountCount(data){
  return request(data,"/discountUseBind/getUserDiscountCount",GET).then(res=>res)
}

export function getUserDiscountPage(data){
  return request(data,"/discount/getUserDiscountPage",GET).then(res=>res)
}


export function getMyCollect(data){
  return request(data,"/collect/getMyCollect",GET).then(res=>res)
}

export function getMiddleInfo(data){
  return request(data,"/scl/getLinkUrl",GET).then(res=>res)
}


export function getArticleList(data){
  return request(data,"/article/articleList",GET).then(res=>res)
}


export function getArticleInfo(data){
  return request(data,"/article/getArticleInfo",GET).then(res=>res)
}

export function changeLikeStatus(data){
  return request(data,"/userLike/addOrdel",GET).then(res=>res)
}

export function changeCollectStatus(data){
  return request(data,"/collect/getAddMyCollect",GET).then(res=>res)
}


export function getCommentList(data){
  return request(data,"/comment/commentList",GET).then(res=>res)
}

export function addComment(data){
  return request(data,"/comment/commentAdd",GET).then(res=>res)
}

export function getArticle(data){
  return request(data,"/article/getArticle",GET).then(res=>res)
}

export function getArticleRecommendConsultant(data){
  return request(data,"/recommend/articleConsultant",GET).then(res=>res)
}


export function getArticleRecommendScl(data){
  return request(data,"/recommend/articleScl",GET).then(res=>res)
}


export function getArticleRecommendByVideo(data){
  return request(data,"/recommend/articleInfo",GET).then(res=>res)
}


export function getAiUsedInfo(data){
  return request(data,"/chatDialogue/problemCount",GET).then(res=>res)
}

export function chatTextToAi(data){
  return request(data, "/chatDialogue/chatBot", POST,{
    throwErr:true
  }).then(res => res)
}


export function getChatHistory(data){
  return request(data,"/chatDialogue/historicalInformation",GET).then(res=>res)
}

export function checkAiInChating(data){
  return request(data,"/chatDialogue/checkIsIng",GET).then(res=>res)
}

export function getRecommendText(data){
  return request(data,"/chatDialogue/originalProblem",GET).then(res=>res)
}

export function getIsNextCouponIsYiyuan(data){
  return request(data,"/taskDiscountBind/isUserMoreSclBind",GET).then(res=>res)
}

export function userExplanation(data){
    return request(data,"/userMain/addSclUser", POST).then(res=>res)
}

export function isUserMember(data){
    return request(data,"/member/isUserMember", GET).then(res=>res)
}
